// JavaScript Document
$.extend({
	dialog: {
		open: function(title, content, type, callback){
			var html = '<div id="dialog-wrapper">'
				+'<div id="dialog">'
				+'<h1 id="dialog-title">'+title+'</h1>'
				+'<div id="dialog-content">'+content+'</div>'
				+'</div>'
				+'</div>'

			function setDialog(){
				$('body').append(html);
				var ww = $(window).width();
				var wh = $(window).height();
				var dialogWrapper = $('#dialog-wrapper');
				var dialog = $('#dialog');
				dialogWrapper.css({
					'width': ww,
					'height': wh
					})
				var dw = dialog.width();
				var dh = dialog.height();
				var pX = (ww-dw)/2;
				var pY = (wh-dh)/2;
				dialog.css({
					'position': 'absolute',
					'top': pY,
					'left': pX
					})
				}
			// init
			setDialog();
			switch(type){
				case 'alert': $('#dialog').append('<button id="dialog-ok">OK</button>') ;
				}
			if(callback){
				callback();
				}
			}
		},
	alert: function(title, content, callback){
		if(title == null) title = 'Alert';
		$.dialog.open(title, content, 'alert', callback);
		},
	confirm: function(title, content, callback){}
})